/**
 * @author caif
 * @fileoverview thumbnailView 
 * @extends file viewer
 */
App.Views.thumbnailView = App.Views.itemView.extend({
	className : "doc-item thumb-item",
	
	events: {
	    "keypress .thumbnail_edit"  : "updateOnEnter",
	    "click .inner-item"    : "updateDetail",
	    "dblclick .inner-item" : "open",
	    "blur .inner-item"     : "close"
	},
	
	initialize : function() {
		var self = this;
        self.constructor.__super__.initialize.apply(self);
        self.model.on('change', self.render, self);
    },
	
	render: function(){
	    var self = this,
	    template = tpl.thumbnail;
	    if(self.model.get('extension')){
	       self.model.set({'uiName': self.model.get('name') + '.' + self.model.get('extension')}, {silent: true});
	    }else{
	       self.model.set({'uiName': self.model.get('name')}, {silent: true});
	    }
	    var data = _.extend( self.model.toJSON() , {processCommon : true });
	    var currentFilter = App.viewInstances.appView.currentFilter;
	    if(currentFilter.fromOwnMe || currentFilter.fromProject){
            data.isOwnMe = true;
        }else if(currentFilter.fromRecycle){
	        data.isRecycle = true;
	    } else if(currentFilter.fromFilesByMe || currentFilter.fromPublic || currentFilter.fromFilesForMe){
	        data.isShare = true;
	    }
        data.rootPath = currentFilter.rootPath;
	    self.$el.html(Mustache.to_html(template, data ));
        if(self.model.get("dataBagId")){
		     data.processCommon = false;
		     self.processDatabag(self.model.get("dataBagId"), self.model.get("extension"), data, template);
		}
		if(self.model.get("folder")){
            self.$el.addClass('folder-item');
		}
	    self.input = self.$('.thumbnail_edit'); 
		return self;
	}
});
